package com.server.task;

import com.server.bean.Instance;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Timer;

/**
 * Description:
 *
 * @author weiruibai.vendor
 * Date: 2023/1/28 11:39
 */
@Slf4j
public class TaskManager {

    public TaskManager(MyTask myTask, Instance instance) {
        Timer timer = new Timer();
        //0表示立即执行一次，以后每隔一段时间执行一次
        timer.schedule(myTask, 0,
                Long.valueOf(instance.getTimeIntervalInSecond()) * 1000);
    }

}
